<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Check if an element has a certain CSS class</title>
<style type="text/css">
  .redColor { 
  	background:red;
  }
  .blueColor { 
  	background:blue;
  }
 </style>
<script type="text/javascript" src="../jquery-1.11.0.js"></script>
<script type="text/javascript">

	$(document).ready(function() {
		
		$("#isTest").click(function() {
			if ($("div").is(".redColor")) {
				$("div").addClass("blueColor");
			}
		});

		$("#reset").click(function() {
			location.reload();
		});
		
	});

</script>
</head>
<body>
	<h1>jQuery check if an element has a certain class</h1>
	<div class="redColor" id="div1">This is a div tag with class name of "redColor"</div>
	<p>
		<button id="isTest">is('.redColor')</button>
		<button id="reset">reset</button>
	</p>
	<br><a href="index.jsp">retour</a>
</body>
</html>
